﻿@model cloudscribe.Web.Common.Models.FormItemDefinition
@inject IStringLocalizer<CloudscribeCommonResources> sr
@{
    var grpClass = "";// input-group
    var spnClass = ""; //input-group-addon
    if (!string.IsNullOrWhiteSpace(Model.IconCssClass))
    {
        grpClass = "input-group";
        spnClass = "input-group-text";

    }
}
<div class="mb-3">
    <label class="form-label" for="@Model.Key">@sr[Model.Label]</label>
    <div class="@grpClass">
        @if (!string.IsNullOrWhiteSpace(Model.IconCssClass) && Model.IconOnLeft)
    {
            <span class="@spnClass"><i class="@Model.IconCssClass" aria-hidden="true"></i></span>
}
        <input id="@Model.Key" name="@Model.Key" value="@ViewData[Model.Key]" title="@Model.Tooltip" class="form-control @Model.CssClass" cs-form-item-definition="@Model" />
        <span class="invalid-feedback field-validation-valid" data-valmsg-for="@Model.Key" data-valmsg-replace="true"></span>
        @Html.ValidationMessage(Model.Key + "Error", new { @class = "text-danger" })
        @if (!string.IsNullOrWhiteSpace(Model.IconCssClass) && !Model.IconOnLeft)
    {
        <div class="input-group-append">
            <span class="@spnClass"><i class="@Model.IconCssClass" aria-hidden="true"></i></span>
        </div>
}
    </div>
    
</div>
